package com.local.videoplayer.activity;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.widget.TextView;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.local.videoplayer.R;
import com.local.videoplayer.adapter.VideoAdapter;
import com.local.videoplayer.bean.FolderBean;
import com.local.videoplayer.bean.VideoBean;

/**
 * Created by ccx on 17/8/14.
 */

public class VideoListActivity extends BaseActivity {
    private RecyclerView mVideoRecycleView;
    private VideoAdapter mAdapter;
    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
       setContentView(R.layout.activity_video_list);
        mVideoRecycleView = findViewByIdExt(R.id.video_rv_list);
        TextView titieTv = findViewByIdExt(R.id.tv_title);
        LinearLayoutManager layoutManager = new LinearLayoutManager(this);
        layoutManager.setOrientation(LinearLayoutManager.VERTICAL);
        mVideoRecycleView.setLayoutManager(layoutManager);
        mAdapter = new VideoAdapter();
        mVideoRecycleView.setAdapter(mAdapter);
        FolderBean bean =  intentData.getParcelable("DATA");
        mAdapter.setNewData(bean.videos);
        titieTv.setText(bean.name);
        mAdapter.setOnItemClickListener(new BaseQuickAdapter.OnItemClickListener() {
            @Override
            public void onItemClick(BaseQuickAdapter adapter, View view, int position) {
                Bundle bundle = new Bundle();
                bundle.putString("DATA", ((VideoBean) adapter.getItem(position)).videoPath);
                bundle.putString("NAME", ((VideoBean) adapter.getItem(position)).videoName);
                goToOthers(VideoPlayActivity.class, bundle);
            }
        });
    }
}
